<template>
  <div class="homeNavBrandZone">
    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
      <div v-for="item in list" :key="item.Id" :title="item" class="ItemX">
        <div class="ItemX_content">
          <router-link
            tag="a"
            :to="{path: 'ProductList', query: {id: (item.cid).match(/fs-(.+)/)[1]}}"
          >
            <img :src="item.imgSrc" alt />
          </router-link>
          <div class="ItemX_content_surface">
            <div class="ItemX_content_value">
              <div class="ItemX_content_item" v-for="item in item.content" :key="item.cId">
                <router-link :to="'Details' + item.cid" tag="a">
                  <span v-if="item.tag" class="tag">{{ item.tag }}</span>
                  <div>
                    <img :src="item.imgSrc" alt class="imginit" />
                    <img :src="img" alt />
                  </div>
                  <p>
                    <span v-html="item.price"></span>
                    <del v-html="item.oldPrice"></del>
                  </p>
                </router-link>
              </div>
            </div>
          </div>
        </div>
      </div>
    </van-list>
  </div>
</template>

<script>
import { getHomeDataList } from "@/api";
export default {
  name: "homeNavBrandZone",
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1,
      img: require("@/assets/icon/defalutv.jpg")
    };
  },
  methods: {
    onLoad() {
      getHomeDataList(this.page).then(res => {
        if (res.code) {
          this.list.push(res.data);
          this.loading = false;
          this.page++;
        } else {
          this.finished = true;
        }
      });
    }
  }
};
</script>

<style scoped>
.ItemX {
  width: 100%;
  overflow: hidden;
  font-size: 0;
}
.ItemX_content {
  background-color: #fff;
  margin: -0.01rem 0.1rem 0.12rem;
}

.ItemX_content > a {
  padding: 0 0.2rem;
  background-color: #fff;
  display: block;
  position: relative;
}

.tag {
  position: absolute;
  top: 0;
  right: 0;
  display: block;
  font-size: 0.16rem;
  color: #fff;
  font-family: PingFang-SC-Medium;
  background-color: #ff4664;
  width: 0.55rem;
  height: 0.3rem;
  line-height: 0.3rem;
  text-align: center;
}

.ItemX_content_item > a div {
  margin-bottom: 0.24rem;
  width: 100%;
  overflow: hidden;
}

.ItemX_content > a > img {
  width: 100%;
  padding: 0.16rem 0;
  height: 3rem;
  vertical-align: top;
}

.imginit {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
}

.ItemX_content_value {
  background-color: #fff;
  width: 100%;
  position: relative;
  overflow: hidden;
  overflow-x: scroll;
  overflow-y: hidden;
  box-sizing: border-box;
  white-space: nowrap;
  padding-right: 0.1rem;
}

.ItemX_content_item {
  position: relative;
  display: inline-block;
  box-sizing: content-box;
  width: 1.95rem;
}

.ItemX_content_item a {
  display: block;
  text-decoration: none;
}

.ItemX_content_item a img {
  width: 100%;
  height: 1.96rem;
}

.ItemX_content_item a p {
  font-size: 0.2rem;
  color: #333;
  margin-bottom: 0.33rem;
  text-align: center;
  font-family: PingFang-SC-Medium;
}

.ItemX_content_item a p del {
  color: #999;
  padding-left: 0.1rem;
  font-size: 0.18rem;
}

.ItemX_content_surface {
  overflow: hidden;
  padding: 0 0.2rem;
}
</style>
